/**
 * 
 */
package com.agilegroup.crm.ui.fragments;

import java.util.Calendar;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Dialog;
import android.app.TimePickerDialog;
import android.os.Build;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.TimePicker;

import com.actionbarsherlock.app.SherlockDialogFragment;

/**
 * @author hisham
 *
 */
@SuppressLint("ValidFragment")
public class TimePickerFragment extends SherlockDialogFragment implements TimePickerDialog.OnTimeSetListener{

	private TextView txtTime;
	
	public TimePickerFragment(TextView txtTime) {
		this.txtTime=txtTime;
	}

	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
	@Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Use the current date as the default date in the picker
        final Calendar c = Calendar.getInstance();
        int hour = c.get(Calendar.HOUR_OF_DAY);
        int minute = c.get(Calendar.MINUTE);
        
        TimePickerDialog dialog = new TimePickerDialog(getActivity(), this, hour, minute, true);
        dialog.setTitle("Set Time");
        return dialog;
    }
	
	@Override
	public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
		txtTime.setText(hourOfDay+":"+minute);
	}
}
